<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:insert="~{include :: header('通知公告列表')}" />
	<th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">
    <div class="container-fluid mt-2 mb-2">
		<div class="row">
	        <div class="btn-group" id="toolbar" role="group">
				<form id="formId">
					<div class="input-group">
						<a class="btn btn-success mr-1" onclick="noticeAdd()" shiro:hasPermission="notice:add">
							<i class="fa fa-plus"></i> 新增
						</a>
						<input type="text" name="noticeTitle" placeholder="请输入标题..." class="form-control">
						<select name="noticeType" class="form-control" th:with="type=${@dict.getType('qdx_notice_type')}">
						<option value="">类型</option>
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
						</select>
						<span class="input-group-append mr-1">
                            <button type="button" class="btn btn-primary" onclick="$.table.search()">
                                <i class="fa fa-search"></i>
                                筛选/搜索
                            </button>
                            <button type="button" class="btn btn-default" onclick="$.form.reset()">
                                <i class="fa fa-refresh"></i>
                                重置
                            </button>
                        </span>
					</div>
				</form>
	        </div>
	        <div class="col-sm-12 select-table table-striped">
	            <table id="bootstrap-table" class="table-striped"></table>
	        </div>
    	</div>
    </div>
    <th:block th:insert="~{include :: footer}" />
	<th:block th:insert="~{include :: bootstrap-table-js}" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('notice:edit')}]];
        var removeFlag = [[${@permission.hasPermi('notice:remove')}]];
        var types = [[${@dict.getType('qdx_notice_type')}]];
        var datas = [[${@dict.getType('qdx_notice_status')}]];
        var prefix = "/notice";

        $(function() {
            var options = {
                url: prefix + "/list.json",
                removeUrl: prefix + "/remove.json",
                modalName: "公告",
                columns: [
				{
					field : 'noticeId', 
					title : '序号',
					align: 'center',
					width : '100px'
				},
				{
					field : 'noticeTitle', 
					title : '公告标题' 
				},
				{
		            field: 'noticeType',
		            title: '公告类型',
		            align: 'center',
					width : '100px',
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(types, value);
		            }
		        },
				{
		            field: 'status',
		            title: '状态',
		            align: 'center',
					width : '100px',
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(datas, value);
		            }
		        },
				{
					field : 'createBy', 
					title : '创建者',
					align: 'center',
					width : '120px',
				},
				{
		            field: 'createTime',
		            title: '创建时间',
					align: 'center',
					width : '180px',
		        },
		        {
		            title: '操作',
		            align: 'center',
					width : '120px',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="noticeEdit(\'' + row.noticeId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.noticeId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

        function noticeAdd() {
			var index = layer.open({
				title: '新增公告',
				content:prefix + '/add.html',
				type: 2,
				shade: 0.2,
				maxmin: true,
				shadeClose: true,
				area: ['90%', '95%']
			});
		}

		function noticeEdit(noticeId) {
			var index = layer.open({
				title: '编辑公告',
				content:prefix + '/edit/'+noticeId,
				type: 2,
				shade: 0.2,
				maxmin: true,
				shadeClose: true,
				area: ['90%', '95%']
			});
		}
    </script>
</body>
</html>